﻿
Imports System.Data
Imports VSModel
Imports Cls_Common
Imports SecurityService
Partial Class Control_WareHouse_Detail
    Inherits System.Web.UI.UserControl
    Private Shared ReadOnly log As log4net.ILog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)
#Region "Sub and Function "
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
         

            If Not Request.QueryString("Id").ToString.Equals("0") Then
                hidID.Value = Request.QueryString("Id")
                ShowData()
            End If
        End If
    End Sub
    Protected Sub ShowData()
        Using data As New VSEntities
            Dim p As Warehouse = (From q In data.Warehouses Where q.Id = hidID.Value Select q).SingleOrDefault
            If Not p Is Nothing Then
                txtBatchno.Text = IIf(IsNothing(p.BatchNo) = True, "", p.BatchNo)

                txtItemcode.Text = IIf(IsNothing(p.ItemCode) = True, "", p.ItemCode)

                txtVendorcode.Text = IIf(IsNothing(p.VendorCode) = True, "", p.VendorCode)


                If Not p.ManufacturedDate Is Nothing Then
                    txtNgaysanxuat.Text = CType(p.ManufacturedDate, Date).ToString("dd/MM/yyyy")
                End If

                If Not p.ExpiredDate Is Nothing Then
                    Dim dtNgayHetHan As Date = CType(p.ExpiredDate, Date)
                    If dtNgayHetHan.ToString("dd/MM/yyyy") <> "01/01/1900" Then
                        txtNgayhethan.Text = dtNgayHetHan.ToString("dd/MM/yyyy")
                    Else
                        txtNgayhethan.Text = ""
                    End If
                End If


                txtKhoiluongthetich.Text = IIf(IsNothing(p.PackingSize) = True, "", p.PackingSize)
                txtQuycachdonggoi.Text = IIf(IsNothing(p.PackingType) = True, "", p.PackingType)
                txtSource.Text = IIf(IsNothing(p.Source) = True, "", p.Source)
                txtPallet.Text = IIf(IsNothing(p.Pallet) = True, "", p.Pallet)
                txtStockOnHand.Text = IIf(IsNothing(p.StockOnHand) = True, "", p.StockOnHand)
                txtBUN.Text = IIf(IsNothing(p.BUN) = True, "", p.BUN)

            End If
        End Using
    End Sub
#End Region

End Class
